a = 7**103+20*7**204-3*7**57+97
s = 0
while a > 0:
    if a%7==6:
        s += 1
    a = a // 7
print(s)